home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / vbfindid.zip / VBFINDID.TXT < prev   
Text File  |  1991-10-23  |  5KB  |  107 lines

  1.                          VBFindID Documentation
  2.      
  3. Introduction:
  4.  
  5. Visual Basic provides no way to determine or define the IDs of Controls in VB 
  6. forms.  There are several API calls that require that the ID of a child
  7. control be supplied, for example SendDlgItemMessage, SetDlgItemInt,
  8. DlrDirList, etc.  The IDs of controls can be determined during run time by
  9. going through a series of SetFocus and API calls, e.g.
  10.  
  11.           aControl.SetFocus
  12.           id_aControl = GetDlgCtrlID(GetFocus())
  13.           bControl.SetFocus
  14.           id_bControl = GetDlgCtrlID(GetFocus())
  15.  
  16. Even though this method will determine the ID of a control it can only be
  17. implemented once a form is shown (or during Form_Paint) and will not work
  18. with VB Labels since SetFocus flags these.  There are many instances when
  19. knowing the ID of a label can be useful, e.g. with API's DlgDirList function.
  20.  
  21. VBFindID is a small WinApp I wrote in Turbo Pascal for Windows (for 
  22. compactness).  It can be used to determine the IDs of VB Controls (including 
  23. Labels) during development of your VB Apps.  Knowing the IDs before hand saves
  24. you from having to determine control IDs during run-time and allows you the 
  25. flexibility to use several API calls during the Form_Load procedure without 
  26. having to show the form and go through a series of SetFocus statements. Also, 
  27. it's the only way I know of to get the IDs of VB labels.
  28.  
  29.  
  30. Using VBFindID:
  31.  
  32. I've installed VBFindID as a Program Item under the Languages Group. This way
  33. I can quickly start it whenever I need to use it with a VB project.  Even
  34. though VBFindID was written as a VB utility, it will find the IDs of any 
  35. legitimate Windows control.  Additionally, it reports the current hWnd
  36. handle of the control (useful only for debugging since this changes all the
  37. time), the Class Name of the control, and finally the control's caption.
  38.  
  39. After you start VBFindID, click on the "Find ID" button to start the search.
  40. VBFindID loads its own cursor which looks like a frame.  The center of the
  41. frame is the cursor's hot spot.  Move the VBFindID custom cursor over the
  42. control whose ID you wish to determine so that the center of the cursor is
  43. over a portion of the control.  You'll notice VBFindID updates its report
  44. label as you move the frame cursor around.  If you want to find the ID of
  45. a button, place the frame cursor over the button on the window you are
  46. researching.  If you want to find the ID of a Label place the cursor over the 
  47. Label.  Do the same for listboxes, combo boxes, option buttons, etc.  Make a 
  48. note of the IDs you're planning on using in your App and press the right 
  49. mouse button (or Escape) to stop the search.  To end the VBFindID session,
  50. click on Quit.
  51.  
  52.  
  53. Visual Basic and Control IDs:
  54.  
  55. VB assigns IDs to controls during design time.  The first control is assigned
  56. ID: 1, and the IDs are incremented with each control added to the form (the
  57. second control's ID will be 2, the third's 3, etc).  If this ID order was
  58. always the case, there would be very little need for VBFindID since you could
  59. make a note of which control you created first, second, third, and so forth,
  60. and immediately know the ID order of your controls.  Running VBFindID in 
  61. design mode this seems to be the case, but when you choose "Run" to run 
  62. your form and inspect the IDs with VBFindID you'll discover that VB reorders 
  63. the IDs in a left to right, top to bottom order.  So, if your first control 
  64. was placed at the bottom left corner it may have an ID of 1 during design 
  65. time but an ID of 5 during run time.
  66.  
  67. You may be wondering: if this is the case then it's hopeless to be able to
  68. accurately determine IDs without the SetFocus/GetFocus routines.  There's
  69. good news:  Once you design your form to your satisfaction, save the form.
  70. When the form is saved the IDs are set for good.  Now, load the form and
  71. "Run" it along with VBFindID.  Make a note of the IDs of the controls you 
  72. need and you're all set.  If you add or delete controls during development 
  73. then simply go through the same steps to determine the correct ID 
  74. assignments.
  75.  
  76.  
  77. About the ID demos:
  78.  
  79. IDDEMO.MAK is the Shell for two demos: IDOPEN and IDOTHER.  
  80.  
  81. IDOPEN is a simple Win3 style File Open dialog without an Edit control.  It
  82. uses DlgDirList and DlgDirSelect as examples of using IDs with VB forms.
  83.  
  84. IDOTHER demos using SetDlgItemInt, SetDlgItemText, SendDlgItemMessage,
  85. GetDlgItemInt, GetDlgItemText, and GetDlgItem.
  86.  
  87.  
  88. Questions/Comments:
  89.  
  90. If you have questions or comments you may reach me via CIS mail at 73667,1755
  91. or on the MSBASIC forum.
  92.  
  93.  
  94. Distribution:
  95.  
  96. If you'd like to share VBFINDID with your friends and colleagues or upload it
  97. to a BBS you may do so only in the form of the original ZIP archive containing
  98. VBFINDID.EXE, VBFINDID.TXT, IDDEMO.MAK, IDDEMO.FRM, IDOPEN.FRM, and 
  99. IDOTHER.FRM. Of course, don't charge anything for VBFINDID or the docs and 
  100. demo files.
  101.  
  102.  
  103. Enjoy,
  104.  
  105. Costas Kitsos
  106. October 1991
  107.